package handlers

import (
	"github.com/gin-gonic/gin"
	"user-mng-sys/models"
)

func CreateOp(c *gin.Context) {
	rid := c.PostForm("rid")
	opname := c.PostForm("opname")

	if rid == "" || opname == "" {
		c.JSON(200, gin.H{
			"code": 500,
			"msg":  "数据不能为空",
		})
		return
	}

	data := models.Op{
		Rid:    rid,
		OpName: opname,
	}

	err := models.DB.Create(&data).Error
	if err != nil {
		c.JSON(200, gin.H{
			"code": 500,
			"msg":  "添加失败",
		})
		return
	}
	c.JSON(200, gin.H{
		"code": 500,
		"msg":  "添加成功",
	})
	return
}
